#ifndef KBBUTTON_H
#define KBBUTTON_H

#include <QPushButton>

class KBButton : public QPushButton
{
    Q_OBJECT
public:
    enum BORDER_RADIUS{
        BORDER_RADIUS_NONE,
        BORDER_RADIUS_LT = 1,
        BORDER_RADIUS_TR = 2,
        BORDER_RADIUS_RB = 4,
        BORDER_RADIUS_LB = 8,
        BORDER_RADIUS_ALL = 0xF,
    };
    KBButton(QWidget *parent = nullptr);
    virtual ~KBButton();

    void setCharId(QChar charId);
    void updateStyleSheet(QString clrNormal, QString clrHover, QString clrChecked, QString clrBoard, QString clrBoardPress, QString clrFontPress, int radius = BORDER_RADIUS_ALL, bool is_lock = false);
    void setShiftState(bool isShift);
    void setCapsStatus(bool isCaps);
    void setCtrlState(bool isCtrl);
    void setAltState(bool isAlt);

protected:
    bool eventFilter(QObject *watched, QEvent *event);

Q_SIGNALS:
    void clicked(QChar charId);

private:
    QPixmap drawSymbolicColoredPixmap(const QPixmap &source, QString cgColor);

private:
    int m_nKeyId = -1;
    bool m_isShift = false;
    bool m_isCtrl = false;
    bool m_isAlt = false;
    bool m_isCaps = false;
    QChar m_charId = QChar::Null;
    QString m_clrBoard;
    QString m_clrNormal;
    QString m_clrBoardPress;
    QString m_clrHover;
    QString m_clrChecked;
    QFont sysFont;
};

#endif // KBBUTTON_H
